package com.swpu.zdl.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.swpu.zdl.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Mapper
public interface StudentMapper extends BaseMapper<Student> {
    @Select("select sno,student_name,yuan_xi,zhuan_ye,nian_ji,gender,phone from student")
    List<Student> getAll();
    @Insert("insert into student(sno,student_name,yuan_xi,zhuan_ye,nian_ji,gender,phone)" +
            "values (#{sno},#{studentName},#{yuanXi},#{zhuanYe},#{nianJi},#{gender},#{phone})")
    boolean addStudent(Student student);
    @Delete("delete from student where sno = #{sno}")
    boolean deleteStudent(String sno);

    List<Student> getAllMsg();

    Boolean updateStudentMsg(@Param("sno") String sno, @Param("student") Student student);
    Student getMsgBySno(String sno);
    @Select("select * from student where student_name like concat('%',#{name},'%')")
    @ResultMap("StudentMap")
    List<Student> getByName(String name);
    @Select("SELECT * from student s join student_xuanke sx on s.sno = sx.sno\n" +
            "WHERE cid = #{id}")
    List<Student> getStudents(Integer id);
}
